package com.etc.controller;

import com.etc.entity.ViewEngageInfo;
import com.etc.service.ViewEngageService;
import com.etc.util.Layui;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
@RequestMapping("/viewEngageInfo")
public class ViewEngageInfoController {

    @Autowired
    ViewEngageService service;

    /**
     * 查询所有订单
     * @return
     */
    @RequestMapping("/allEngage")
    @ResponseBody
    public Layui allEngage(@RequestParam(value = "page",defaultValue = "1")int page,
                           @RequestParam(value = "limit",defaultValue = "10")int limit){
        PageInfo<ViewEngageInfo> pageInfo=service.getAllEngage(page,limit);
        return Layui.data(pageInfo.getTotal(),pageInfo.getList());
    }

    /**
     * 修改订单状态
     * @param s
     * @param eId
     */
    @RequestMapping("/upStatus")
    @ResponseBody
    public boolean upStatus(@RequestParam("s") int s,
                            @RequestParam("eId") int eId){
        boolean flag=service.updateStatus(s,eId);
        return flag;
    }

    @RequestMapping("/pay")
    public ModelAndView pay(){
        ModelAndView mv=new ModelAndView();
        mv.setViewName("alipay/index02");
        return mv;
    }
}
